package cn.mxz.xmu.robots.library;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import cn.mxz.xmu.interfaces.robot.ILibrary;
import cn.mxz.xmu.robots.library.xmu.XmuLibrary;

/**
 * 图书馆方法调用入口
 * 
 * @author dongchao <dongchao@mouge.wang>
 * @since 2015-07-27
 *
 */
@Component
public class Library implements ILibrary
{
	public static Logger logger = LoggerFactory.getLogger(Library.class);

	@Override
	public String param(String method, String value)
	{
		return reflect(method, value);
	}

	/**
	 * 反射封装，防止多个过长的方法的出现
	 * 
	 * @param schoolId
	 *            学校ID
	 * @param method
	 *            调用方法
	 * @param param
	 *            调用方法需要的参数
	 * @return 调用结果
	 */
	public String reflect(String method, String param)
	{
		XmuLibrary library = new XmuLibrary();

		String result = null;

		if (method.equals("queryBooks"))
		{
			result = library.queryBooks(param);
		}
		else if (method.equals("bookDetails"))
		{
			result = library.bookDetails(param);
		}

		logger.info(" method = " + method + " param = " + param + " result = " + result);

		return result;

	}

}
